GBML manual / Backgrounds

background_scroll_speed

Says how far bg moves compared with the camera, in percent, across and down. 100 is what a background does by itself: it moves with the room. 50 moves it half as far, so it looks far away. 0 keeps it fixed to the screen.

Works differently on Game Boy - The Game Boy moves the room's own picture a part of the camera's move, across only, in whole pixels rounded down. It works in a room of 256 by 256 pixels or smaller (in a bigger room the picture moves with the room), and a strip moves with the room.

Works differently on Game Boy Color - The Game Boy Color moves the room's own picture a part of the camera's move, across and down, in whole pixels rounded down. It works in a room of 256 by 256 pixels or smaller (in a bigger room the picture moves with the room), and a strip moves with the room.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

background_scroll_speed(bg, x_percent, y_percent)

Arguments

NameType
bgbackground
x_percentint
y_percentint

Returns

Nothing.

Description

Says how far bg moves compared with the camera, in percent, across (x_percent) and down (y_percent). A no-op on nothing. It applies to a background a Draw event draws with draw_background, takes effect the next time it is drawn, and stays until you destroy the background.

x_percent or y_percentWhat the picture does
100moves with the room, as a background does by itself
50moves half as far as the camera: it looks far away
0stays where it is on the screen
a minus numbermoves the other way

Use a number from -300 to 300. The picture sits where draw_background puts it when the camera's top-left corner is at the room's (0, 0); from there it moves the part of the camera's move that you asked for, in whole pixels, so it never shakes.

A background drawn in a Draw GUI event is fixed to the screen already, so this changes nothing there. The room's own picture has the same setting in the Tile Palette, called Scroll speed (under its Picture in Backgrounds, or in Tile layers); this call is for the pictures you make with background_create. A picture the console repeats past its edge keeps repeating while it scrolls, so a picture that is too narrow for the speed shows its own edge again (background_repeat changes that).

A game that never sets a scroll speed does not carry any of this.

Example

backdrop = background_create(0, 0, ts_doc_dungeon);
background_scroll_speed(backdrop, 50, 100);

Makes a background that moves half as far sideways as the camera does, and all the way up and down.

On the GBA

A no-op on `nothing`. It applies to a background a Draw event draws (draw_background) and takes effect the next time it is drawn; it stays until you destroy the background. A background drawn in a Draw GUI event is fixed to the screen already, so this changes nothing there. The picture is put where draw_background says when the camera’s top-left corner is at the room’s (0, 0), and from there it moves x_percent of what the camera moves across and y_percent of it down, in whole pixels, so it does not shake. Use a number from -300 to 300; a negative number moves the picture the other way. The room’s own picture has the same setting in Room Properties, called Scroll speed. A picture the console repeats past its edge keeps repeating while it scrolls, so a picture that is not wide enough for the speed shows its own edge again (see background_repeat to change that). A game that never sets a scroll speed does not carry any of this.

See also: Backgroundsdraw_backgroundbackground_createbackground_repeatcamera_set